package com.samoilovich.belarustoday.tech.fragments;

import android.content.Context;
import android.view.View;
import android.widget.AdapterView;
import com.samoilovich.belarustoday.R;
import com.samoilovich.belarustoday.datemodel.CategoryModel;
import com.samoilovich.belarustoday.handlers.NewsHandler;
import com.samoilovich.belarustoday.basefragments.NewsBaseFragment;
import com.samoilovich.belarustoday.tech.TechActivity;
import com.samoilovich.belarustoday.tools.Utility;

public class TechMainFragment extends NewsBaseFragment {
    public TechMainFragment() {
    }

    public TechMainFragment(Context context, String tag) {
        mListItemResId = R.layout.category_list_item;
        mOnItemClickListener = new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
                CategoryModel category = mAdapter.getItem(position);
                ((TechActivity) getActivity()).setTechCategoryFragment(category);
            }
        };
        sTitle = R.string.technologies_label;
        mNoImageId = R.drawable.category_no_image;
        mInProgress = false;
        mWasCreateNormal = true;
        getCategories(context);
    }

    @Override
    protected  void getCategories(Context context) {
        super.getCategories(context);
        if (Utility.hasInternetConnection(context)) {
            mInProgress = true;
            NewsHandler.getInstance().getCategories(this, 1);
        }
    }

}
